#include <iostream>
using namespace std;
int main()
{
	int t;
	int N;
	int count;
	cin >> t;
	while(t--)
	{
		cin >> N;
		count = 0;
		while(N!=1)
		{
			if(N%2)
			{				
				if (count != 0)
					cout << " ";
				cout << N;
				N = N * 3 + 1;
				count++;
			}
			else
			{
				N = N / 2;
			}
		}
		if (!count)
			cout << "No number can be output !" << endl;
		else
			cout << endl;
	}
}